package com.shiguiwu.springmybatis.designpattern.abstractfactory.scene.factory.domain;

import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.util.concurrent.TimeUnit;

/**
 * @description: iir集群
 * @author: stone
 * @date: Created by 2021/8/12 23:31
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springmybatis.designpattern.abstractfactory.scene.factory.domain
 */
@Slf4j
public class RedisIIR {


    private StringRedisTemplate stringRedisTemplate;

    public RedisIIR(StringRedisTemplate stringRedisTemplate) {
        this.stringRedisTemplate = stringRedisTemplate;
    }

    public void set(String key, String value) {
        log.info("集群iir方式==================>{}-{}", key, value);
        stringRedisTemplate.opsForValue().set(key, value);
    }

    public void setExpire(String key, String value, long time, TimeUnit timeUnit) {
        log.info("集群iir方式==================>{}-{}-{}-{}", key, value, time, timeUnit);

        stringRedisTemplate.opsForValue().set(key, value, time, timeUnit);
    }

    public String get(String key) {
        return stringRedisTemplate.opsForValue().get(key);
    }

    public void del(String key) {
        stringRedisTemplate.delete(key);
    }


}
